package com.future.mayi.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.future.baselib.utils.CommonUtils;
import com.future.baselib.utils.ToastUtil;
import com.future.mayi.R;
import com.future.mayi.constant.AppCst;

/**
 * Created by 周大虎 on 2018/3/9.
 */

public class GoodsShareLinkDialog extends Dialog {


    public GoodsShareLinkDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        setCancelable(false);
        init(context);
    }

    private String goodsCode;
    private Context mContext;

    private void init(Context context) {
        mContext = context;
        View layout = LayoutInflater.from(context).inflate(R.layout.dialog_share_goods_link, null);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        setContentView(layout, params);
        findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();

            }
        });
        findViewById(R.id.tv_enter).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CommonUtils.clipData(mContext, ((TextView) findViewById(R.id.tv_content)).getText().toString());
                AppCst.setShareCode(goodsCode);
                ToastUtil.getInstance().show(mContext, "复制成功");
                dismiss();
            }
        });
    }


    public void show(String title, String goodsCode) {
        this.goodsCode = goodsCode;
        ((TextView) findViewById(R.id.tv_content)).setText(AppCst.Shre_Content_Start + title + "）有兴趣的朋友快来看看！€" + goodsCode + AppCst.Shre_Content_End);
        super.show();
    }


}
